<?php
include("utils.php");
//=====================================================language=============================================
if($_SESSION['langname']=="")
{
	$language_url="languages/"."english".'/index_add_language.php';
	//$langid='1';
}
else
{
	$language_url="languages/".$_SESSION['langname'].'/index_add_language.php';
	//$langid=$_SESSION['langId'];
	$binhtd = "hello"
}


include_once("$language_url");
//======================================================End============================================
if($_POST['mode']=="login")
{
 	login();
}
else
{
main_content("main();");
}
function login()
{
$REMEmber=$_REQUEST['RememberMe'];

$username=$_REQUEST['uname'];
$PASSword=$_REQUEST['password'];
	$login_sql="SELECT *  FROM ".SITEUSER." WHERE username='".mysql_escape_string($_REQUEST['uname'])."' AND password='".md5(mysql_escape_string($_REQUEST['password']))."' ";
//echo $login_sql;
		$login_rs=mysql_query($login_sql) or die(mysql_error());
		if(mysql_num_rows($login_rs)>0)
		{
				$login_row=mysql_fetch_array($login_rs);
				$_SESSION['siteuserId'] = $login_row['siteuserId'];
				echo $_SESSION['username']=$login_row['username'];
				$_SESSION['fName']=$login_row['fName'];
				$_SESSION['lName']=$login_row['lName'];
				$_SESSION['email']=$login_row['email'];
				$_SESSION['registrationDate']=$login_row['registrationDate'];
				$_SESSION['company']=$login_row['company'];
				$_SESSION['time']=time();

				if(isset($REMEmber)=='Y')
					{
					setcookie('REMEMBERUSER_NAME',$username,time() + (int)(3*24*3600));
					setcookie('REMEMBERUSER_PASS',$PASSword,time() + (int)(3*24*3600));
					}
				if(isset($REMEmber)=='')
					{
					setcookie('REMEMBERUSER_NAME','',time()-3*24*3600);
					setcookie('REMEMBERUSER_PASS','',time()-3*24*3600);
					}


			header("Location:start.php");

		}
		else
		{
			
		 $new_msg=MSG_g;
		 $GLOBALS['msg']= $new_msg;
		
		}
main_content("main();");

}
function main()
{
 if($_SESSION['siteuserId']!='') 
	{ 
include_once("main_redirect.php");
	
	} 
else 	
	{ 

include_once("middle_log.php");
	
 	}

if($_SESSION['langname']=="")
{
	
	$langid='1';
	$advertisepageId='5';
	$publisherpageId='7';
}
else
{
	
	$langid=$_SESSION['langId'];
	$advertisepageId='6';
	$publisherpageId='8';
}

//echo "SELECT * FROM ".STATICPAGE." where pageId='".$advertisepageId."' and langId='".$langid."'";
$sqlAdvertiser=mysql_query("SELECT * FROM ".STATICPAGE." where pageId='".$advertisepageId."' and langId='".$langid."'");
$fetAdvertiseval=mysql_fetch_array($sqlAdvertiser);
$adverTitle=$fetAdvertiseval['pageName'];
$adverDes=$fetAdvertiseval['contents'];


$sqlPublisher=mysql_query("SELECT * FROM ".STATICPAGE." where pageId='".$publisherpageId."' and langId='".$langid."'");
$fetPublisherval=mysql_fetch_array($sqlPublisher);
$publiTitle=$fetPublisherval['pageName'];
$publiDes=$fetPublisherval['contents'];


?>
		
<!-- /banner and login -->

	</td>
  </tr>
  
  
  
  
<?php
	if($_SESSION['siteuserId']=='')
	{
?>
  <tr>
    <td>
		<!-- content area -->
<table width="831" class="center"  cellspacing="0" cellpadding="0">
  <tr>
  
  	<!-- left part -->
    <td align="left" valign="top">
    	<table width="100%" cellspacing="0" cellpadding="0">
	
          <tr>
            <td align="left" valign="top">
            	<table width="100%" cellspacing="0" cellpadding="0">
                  <tr>
                  	<!-- advertise table -->
                    <td align="left" valign="top" class="advertise_table">
                    	<table width="100%" cellspacing="0" cellpadding="0">
                          <tr>
                            <td valign="bottom"><img src="images/table_lt_top.jpg" alt="" /></td>
                            <td class="table_top_mid"></td>
                            <td valign="bottom"><img src="images/table_rt_top.jpg" alt="" /></td>
                          </tr>
		
                          <tr>
                            <td valign="top" class="table_leftSide">&nbsp;</td>
                            <td align="left" valign="top">
				
                            	<table width="100%" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td align="left" valign="top" class="sky font-20 border_bottom"><?=$adverTitle;?></td>
                                  </tr>
                                  <tr>
                                    <td align="left" class="font-12 black advertise_tableTxt">
                                   <?=$adverDes;?>
                                    </td>
                                  </tr>
                                </table>
                            </td>
                            <td valign="top" class="table_rightSide">&nbsp;</td>
                          </tr>
                          <tr>
                            <td align="left" valign="top"><img src="images/table_lt_bottom.jpg" alt="" /></td>
                            <td align="left" valign="top" class="table_bottom_mid">&nbsp;</td>
                            <td align="left" valign="top"><img src="images/table_rt_bottom.jpg" alt="" /></td>
                          </tr>
                        </table>
                    </td>
                  	<!-- /advertise table -->                    
                    
                    <!-- publisher table -->
                    <td align="left" valign="top" class="advertise_table">
                    	<table width="100%" cellspacing="0" cellpadding="0">
                          <tr>
                            <td valign="bottom"><img src="images/table_lt_top.jpg" alt="" /></td>
                            <td class="table_top_mid"></td>
                            <td valign="bottom"><img src="images/table_rt_top.jpg" alt="" /></td>
                          </tr>
                          <tr>
                            <td valign="top" class="table_leftSide">&nbsp;</td>
                            <td align="left" valign="top">
                            	<table width="100%" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td align="left" valign="top" class="green font-20 border_bottom"><?=$publiTitle;?></td>
                                  </tr>                                  
                                  <tr>
                                    <td align="left" class="font-12 black advertise_tableTxt">
                                    	<?=$publiDes;?>
                                    </td>
                                  </tr>
                                </table>
                            </td>
                            <td valign="top" class="table_rightSide">&nbsp;</td>
                          </tr>
                          <tr>
                            <td align="left" valign="top"><img src="images/table_lt_bottom.jpg" alt="" /></td>
                            <td align="left" valign="top" class="table_bottom_mid">&nbsp;</td>
                            <td align="left" valign="top"><img src="images/table_rt_bottom.jpg" alt="" /></td>
                          </tr>
                        </table>
                    </td>
                  	<!-- /publisher table -->                                              
                  </tr>
		
                </table>
            </td>
          </tr>
          <tr><!-- advertise -->
	<?php
		$sqlbanner=mysql_query("select * from ".SITEBANNER."");
		$fetchval=mysql_fetch_array($sqlbanner);
		if($fetchval['bannerImage']=='' || !file_exists('admin/banner_image_thumb/'.$fetchval['bannerImage']))
				$bannerimagePath = '<img border="0" src="admin/banner_image/no_image.jpg" height="81" width="482" />';
			else
				$bannerimagePath = '<img border="0" src="admin/banner_image_thumb/'.$fetchval['bannerImage'].'" height="81" width="482"/>';
	?>
            <!-- add -->
                    <td align="left" valign="top">
                    	<table width="100%" cellspacing="0" cellpadding="0">
                          <tr>
                            <td valign="bottom"><img src="images/table_lt_top.jpg" alt="" /></td>
                            <td class="table_top_mid"></td>
                            <td valign="bottom"><img src="images/table_rt_top.jpg" alt="" /></td>
                          </tr>
                          <tr>
                            <td valign="top" class="table_leftSide">&nbsp;</td>
                            <td align="left" valign="top">
                            	<?=$bannerimagePath;?>
                            </td>
                            <td valign="top" class="table_rightSide">&nbsp;</td>
                          </tr>
                          <tr>
                            <td align="left" valign="top"><img src="images/table_lt_bottom.jpg" alt="" /></td>
                            <td align="left" valign="top" class="table_bottom_mid">&nbsp;</td>
                            <td align="left" valign="top"><img src="images/table_rt_bottom.jpg" alt="" /></td>
                          </tr>
                        </table>
                    </td>
                  	<!-- /add --> 
          </tr><!-- /advertise -->
        </table>
    </td>
  	<!-- /left part -->    
    
    <!-- right part -->
    <!-- latest news table -->
                    <td align="left" valign="top" class="latestNews_table">
                    	<table width="100%" cellspacing="0" cellpadding="0">
                          <tr>
                            <td valign="bottom"><img src="images/table_lt_top.jpg" alt="" /></td>
                            <td class="table_top_mid"></td>
                            <td valign="bottom"><img src="images/table_rt_top.jpg" alt="" /></td>
                          </tr>
                          <tr>
                            <td valign="top" class="table_leftSide">&nbsp;</td>
                            <td align="left" valign="top">
                            	<table width="100%" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td align="left" valign="top" class="pink font-20 border_bottom">Latest News</td>
                                  </tr>        
                                  <tr>
                                  	<td><img src="images/spacer.gif" alt="" height="5" /></td>
                                  </tr>
				<?php
					$sqlFetchNews=mysql_query("select * from ".SITENEWS." order by rand() limit 0,2");
					$count='1';
					while($fetcVal=mysql_fetch_array($sqlFetchNews))
					{
						$newsTitle=$fetcVal['newsTitle'];
						$newsDesc=$fetcVal['newsDetails'];
				?>
                                  <tr>
                                  	<td class="left_padding">
                                    	<table width="100%" cellspacing="0" cellpadding="0">
                                          <tr>
                                            <td class="latest_heading1"><?=$count;?></td>
                                            <td class="font-11 latest_heading2"><strong><?=$newsTitle;?></strong></td>
                                          </tr>
                                        </table>
                                    </td>
                                  </tr>             
                                  <tr>
                                    <td align="left" class="font-12 black latestNews_txt left_padding">
                                    	<?=$newsDesc;?>

                                    </td>
                                  </tr>
                                  
                                  <tr><td><img src="images/spacer.gif" alt="" height="4" /></td></tr>
                                  <?php
					$count++;
					}
				  ?>
                                  <!--<tr>
                                  	<td class="left_padding">
                                    	<table width="100%" cellspacing="0" cellpadding="0">
                                          <tr>
                                            <td class="latest_heading">2</td>
                                            <td class="font-11 latest_heading2"><strong>News Headeing</strong></td>
                                          </tr>
                                        </table>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td align="left" class="font-12 black latestNews_txt left_padding">
                                    	"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi 
                                    </td>
                                  </tr>-->
                                  <tr>
                                  	<td>
                                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                          <tr>
                                            <td><img src="images/spacer.gif" alt="" width="210" height="14" /></td>
                                            <td class="more"><a href="#" class="moreLink">more...</a></td>
                                          </tr>
                                        </table>
                                    </td>
                                  </tr>
                                </table>
                            </td>
                            <td valign="top" class="table_rightSide">&nbsp;</td>
                          </tr>
                          <tr>
                            <td align="left" valign="top"><img src="images/table_lt_bottom.jpg" alt="" /></td>
                            <td align="left" valign="top" class="table_bottom_mid">&nbsp;</td>
                            <td align="left" valign="top"><img src="images/table_rt_bottom.jpg" alt="" /></td>
                          </tr>
                        </table>
                    </td>
                  	<!-- /latest news table -->    
    <!-- /right part -->    
  </tr>

</table>
<?php }} 

?>
<?php echo ''; ?><?php echo ''; ?>
